package com.cssy.yd.logic.web;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.cssy.authority.service.IScUserRolewhPlaceService;
import com.cssy.base.web.BaseController;
import com.cssy.base.web.BodyMsg;
import com.cssy.xxkj.logic.entity.LogicWhCheckTaskDO;
import com.cssy.xxkj.logic.entity.LogicWhCheckTaskItemDO;
import com.cssy.xxkj.logic.service.ILogicWhCheckTaskService;
import com.cssy.yd.basic.service.IBasicStorageService;
import com.cssy.yd.logic.entity.LogicWhCheckDO;
import com.cssy.yd.logic.entity.LogicWhCheckDetailsDO;
import com.cssy.yd.logic.entity.LogicWhCheckItemDO;
import com.cssy.yd.logic.entity.LogicWhCheckMissionDO;
import com.cssy.yd.logic.entity.LogicWhCheckMissionItemDO;
import com.cssy.yd.logic.service.ILogicWHCheckService;
import com.cssy.yd.logic.service.ILogicWhCheckMissionService;
import com.cssy.yd.logic.util.SqlUtil;
import com.plat.exception.SyBaseException;
import com.plat.helper.JqGridHandler;
import com.plat.helper.SearchCondition;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
import com.plat.util.DateUtils;
import com.plat.util.ExcelUtil;
import com.plat.util.GlobalResLoader;
import com.plat.util.OperationFlag;
import com.plat.util.json.OutJsonGrid;
import com.yuendong.sy.exception.SyCodeException;

@Controller
@RequestMapping("/yd/logic/whcheck")
public class WHCheckController extends BaseController<LogicWhCheckDO> {
	private static final String MANAGER = "/yd/logic/pandian/WHCheckManager";// 列表页面
	private static final String EIDT = "/yd/logic/pandian/WHCheckMissionOperation";// 添加、修改、显示页面
	private static final String whCheckDetatilsManager = "/yd/logic/pandian/WhCheckDetatilsManager";// 盘点明细报表
	private static final String UPLOAD = "/yd/logic/pandian/WHCheckUpload";// 添加、修改、显示页面
	
	@Resource(name = "logicWHCheckService")
	private ILogicWHCheckService logicWHCheckService;
	
	@Resource(name = "logicWhCheckMissionService")
	private ILogicWhCheckMissionService logicWhCheckMissionService;
	@Resource(name = "basicwhService")
	private IBasicStorageService basicwhService;
	
	@Resource(name="scUserRolePlaceService")
	private IScUserRolewhPlaceService scUserRolePlaceService;
	
	@Resource(name="logicWhCheckTaskService")
	private ILogicWhCheckTaskService logicWhCheckTaskService;

	public String manager(HttpServletRequest request, Model model)
			throws Exception {
		model.addAttribute("wh",SqlUtil.sqlUtil.roleWH(request, scUserRolePlaceService));
		return MANAGER;
	}

	@Override
	public void list(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		JqGridHandler hander = new JqGridHandler(request);
		SearchConditions scs = new SearchConditions();
		hander.getWheres(scs);
//		scs.setOrderBy("dctime desc");
		scs.setRemovedProperty(null);
		scs.addCondition("removed", 0l);
		scs.setOrderBy("bizCreatorDate desc");
		Map<String,Object> sqlMap = SqlUtil.sqlUtil.roleWhSqlFilter(request, scUserRolePlaceService,"zd001WhCode");
		scs.addCondition((String)sqlMap.get("option"), (List)sqlMap.get("roleWhList"));
//		SearchResult result = logicWHCheckService.findListByExample(scs);
		SearchResult result =logicWhCheckTaskService.findListByExample(scs);
		OutJsonGrid out = new OutJsonGrid(result);
		out.printJSon(response);

	}

	@RequestMapping("/pditemlist")
	public void pditemlist(HttpServletRequest request, HttpServletResponse response, Model model)
			throws Exception {
		String checkMissionID = request.getParameter("checkmissionid");
		List<LogicWhCheckMissionItemDO> cmlist = new ArrayList<LogicWhCheckMissionItemDO>();
		List<LogicWhCheckItemDO> checklist = new ArrayList<LogicWhCheckItemDO>();
		cmlist = logicWhCheckMissionService.findItemListByCheckMissionID(checkMissionID);
		for(LogicWhCheckMissionItemDO cmi : cmlist) {
			LogicWhCheckItemDO ciDO = new LogicWhCheckItemDO();
			ciDO.setMaterialsID(cmi.getMaterialsID());
			ciDO.setCode(cmi.getCode());
			ciDO.setName(cmi.getName());
			ciDO.setMaType(cmi.getMaType());
			ciDO.setSpec(cmi.getSpec());
			ciDO.setUnit(cmi.getUnit());
			ciDO.setBatch(cmi.getBatch());
			ciDO.setStatus(cmi.getStatus());
			//一等品
			ciDO.setYdengQuantityWH(cmi.getYdengQuantityWH()==null?Double.parseDouble("0.0"):cmi.getYdengQuantityWH());  
			ciDO.setYdengQuantityPD(ciDO.getYdengQuantityWH()); 
			ciDO.setYdengQuantityCY(ciDO.getYdengQuantityPD()-ciDO.getYdengQuantityWH());
			//次品
			ciDO.setCipinQuantityWH(cmi.getCipinQuantityWH()==null?Double.parseDouble("0.0"):cmi.getCipinQuantityWH());  
			ciDO.setCipinQuantityPD(ciDO.getCipinQuantityWH()); 
			ciDO.setCipinQuantityCY(ciDO.getCipinQuantityPD()-ciDO.getCipinQuantityWH());
			//旧品
			ciDO.setJiupinQuantityWH(cmi.getJiupinQuantityWH()==null?Double.parseDouble("0.0"):cmi.getJiupinQuantityWH());  
			ciDO.setJiupinQuantityPD(ciDO.getJiupinQuantityWH()); 
			ciDO.setJiupinQuantityCY(ciDO.getJiupinQuantityPD()-ciDO.getJiupinQuantityWH());
			//冻结
			ciDO.setFreezeQuantityWH(cmi.getFreezeQuantityWH()==null?Double.parseDouble("0.0"):cmi.getFreezeQuantityWH());  
			ciDO.setFreezeQuantityPD(ciDO.getFreezeQuantityWH()); 
			ciDO.setFreezeQuantityCY(ciDO.getFreezeQuantityPD()-ciDO.getFreezeQuantityWH());
			
			/*//在途
			ciDO.setTransitQuantityWH(lwsv.getBhgquantity()==null?Double.parseDouble("0.0"):lwsv.getBhgquantity());  
			ciDO.setTransitQuantityPD(ciDO.getTransitQuantityWH()); 
			ciDO.setTransitQuantityCY(ciDO.getTransitQuantityPD()-ciDO.getTransitQuantityWH());*/
			
			//总库存(不含在途的数量）
			ciDO.setQuantityWH(ciDO.getYdengQuantityWH()+ciDO.getCipinQuantityWH()+ciDO.getJiupinQuantityWH()+ciDO.getFreezeQuantityWH());  
			ciDO.setQuantityPD(ciDO.getQuantityWH()); 
			ciDO.setQuantityCY(ciDO.getQuantityPD()-ciDO.getQuantityWH());

			checklist.add(ciDO);
		}
		SearchResult result =new SearchResult();
		result.setResults(checklist);
		result.setRecordCount(checklist.size());
		OutJsonGrid out=new OutJsonGrid(result);
		out.printJSon(response);
	}
	
	@Override
	public String operationForm(HttpServletRequest request,
			@PathVariable String id, @PathVariable String flag, Model model)
			throws Exception {
		if (OperationFlag.ADD.equals(flag)) {// 选择盘点时操作
			model.addAttribute("flag", "ADD");
			model.addAttribute("xx", "1");
			SearchConditions scs = new SearchConditions();
			scs.setRemovedProperty(null);
			scs.addCondition("removed", 0l);
			scs.addCondition("zd003BillStatus", "1,2,5", SearchCondition.OP_IN);
			scs.setOrderBy("bizCreatorDate desc");
			Map<String,Object> sqlMap = SqlUtil.sqlUtil.roleWhSqlFilter(request, scUserRolePlaceService,"zd001WhCode");
			scs.addCondition((String)sqlMap.get("option"), (List)sqlMap.get("roleWhList"));
//			SearchResult sr = logicWhCheckMissionService.findListByExample(scs);
			SearchResult sr =logicWhCheckTaskService.findListByExample(scs);
			List<LogicWhCheckTaskDO> missionlist= sr.getResults();
			model.addAttribute("missionlist", missionlist);
		} else {
//			LogicWhCheckDO lpd = logicWHCheckService.findListById(id);
			LogicWhCheckTaskDO lpd=logicWhCheckTaskService.findListById(id);
			//List<LogicWhCheckItemDO> pditemlist = logicWHCheckService.findItemListByCheckID(lpd.getId());
			model.addAttribute("pd", lpd);
			//model.addAttribute("pditemlist", pditemlist);
		}
		return EIDT;
	}
	
	@RequestMapping("/griditems")
	public void griditems(HttpServletRequest request,HttpServletResponse response) throws Exception{
		String id = request.getParameter("id");
		if(StringUtils.isNotBlank(id)){
//			LogicWhCheckDO lpd = logicWHCheckService.findListById(id);
			LogicWhCheckTaskDO lpd=logicWhCheckTaskService.findListById(id);
//			List<LogicWhCheckItemDO> pditemlist = logicWHCheckService.findItemListByCheckID(lpd.getId());
			List<LogicWhCheckTaskItemDO> pditemlist=logicWhCheckTaskService.findItemListByCheckTsdkID(lpd.getId());
			OutJsonGrid out = new OutJsonGrid(pditemlist);
			out.printJSon(response);
		}
	}

	@Override
	public Map<String, Object> save(HttpServletRequest request,
			LogicWhCheckDO curAP, BindingResult result, Model model)
			throws SyBaseException, SyCodeException {
		BodyMsg bodyMap = BodyMsg.getInstance();
		String checkdata = request.getParameter("checkdata");
		if (checkdata == null && "".equals(checkdata)) {
			bodyMap.isFail();
			bodyMap.configWebInfor("盘点内容不能为空！");
			return bodyMap.modelMap;
		}
		try {
				logicWHCheckService.commit(request, curAP);
			
			bodyMap.isSuccess();
			bodyMap.configWebInfor(GlobalResLoader.getOpsuccess());
			bodyMap.configWebId(curAP.getId());
		} catch (Exception e) {
			e.printStackTrace();
			bodyMap.isFail();
			bodyMap.configWebInfor(GlobalResLoader.getOpfailed()
					+ e.getMessage());
		}
		return bodyMap.modelMap;
	}

	@Override
	public Map<String, Object> delete(HttpServletRequest request,
			HttpServletResponse response, Model model) throws Exception {
		/*BodyMsg bodyMap = BodyMsg.getInstance();
		try {
			String ids = request.getParameter("ids");
			String[] fields=ids.split(",");
			for(String field : fields){
				LogicWhCheckDO ld = logicWHCheckService.findListById(field);
				if (ld != null) {
					ld.setRemoved(1);
					logicWHCheckService.update(ld, SessionUtil.getUser(request));
				}
			}
			bodyMap.isSuccess(GlobalResLoader.getOpsuccess());
		} catch (Exception e) {
			e.printStackTrace();
			bodyMap.isFail(GlobalResLoader.getOpfailed() + e.getMessage());
		}
		return bodyMap.modelMap;*/
		return null;
	}
	
	@RequestMapping("/whCheckDetatils")
	public String findWhCheckDetatilsManager(HttpServletRequest request,
			Model model) {
		model.addAttribute("wh", basicwhService.findwh(request));
		return whCheckDetatilsManager;
	}

	@RequestMapping("/whCheckDetatilsList")
	public void findWhCheckDetatils(HttpServletRequest request,
			HttpServletResponse response) {
		JqGridHandler hander = new JqGridHandler(request);
		SearchConditions scs = new SearchConditions();
		hander.getWheres(scs);
		scs.setRemovedProperty(null);
		scs.addCondition("lwc.billstatus", "1",SearchCondition.OP_EQUAL);
		 Map<String,Object> sqlMap = SqlUtil.sqlUtil.roleWhSqlFilter(request, scUserRolePlaceService,"lwc.whcode");
		 scs.addCondition((String)sqlMap.get("option"), (List)sqlMap.get("roleWhList"));
		SearchResult result = logicWHCheckService.findListDetatils(scs);
		List<LogicWhCheckDetailsDO> list = result.getResults();
		OutJsonGrid out = new OutJsonGrid(result);
		out.printJSon(response);
	}
	
	@RequestMapping("/exportAll")
	public void exportAll(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		JqGridHandler hander = new JqGridHandler(request);
		SearchConditions scs = new SearchConditions();
		scs.clearCondition();
		if (!"".equals(hander.getQueryValue("lwc.dctime"))
				&& hander.getQueryValue("lwc.dctime") != null) {
			scs.addCondition(
					"lwc.dctime",
					new String(hander.getQueryValue("lwc.dctime").getBytes(
							"ISO-8859-1"), "UTF-8"), SearchCondition.OP_GREATER);
		}
		if (!"".equals(hander.getQueryValue("lwc.dctime"))
				&& hander.getQueryValue("lwc.dctime") != null) {
			scs.addCondition(
					"lwc.dctime",
					new String(hander.getQueryValue("lwc.dctime").getBytes(
							"ISO-8859-1"), "UTF-8"), SearchCondition.OP_SMALLER);
		}
		if (!"".equals(hander.getQueryValue("lwc.whname"))
				&& hander.getQueryValue("lwc.whname") != null) {
			scs.addCondition(
					"lwc.whname",
					new String(hander.getQueryValue("lwc.whname").getBytes(
							"ISO-8859-1"), "UTF-8"), SearchCondition.OP_LIKE);
		}
		if (!"".equals(hander.getQueryValue("lwci.code"))
				&& hander.getQueryValue("lwci.code") != null) {
			scs.addCondition(
					"lwci.code",
					new String(hander.getQueryValue("lwci.code").getBytes(
							"ISO-8859-1"), "UTF-8"), SearchCondition.OP_LIKE);
		}
		if (!"".equals(hander.getQueryValue("lwci.name"))
				&& hander.getQueryValue("lwci.name") != null) {
			scs.addCondition(
					"lwci.name",
					new String(hander.getQueryValue("lwci.name").getBytes(
							"ISO-8859-1"), "UTF-8"), SearchCondition.OP_LIKE);
		}
		if (!"".equals(hander.getQueryValue("lwc.checkcode"))
				&& hander.getQueryValue("lwc.checkcode") != null) {
			scs.addCondition(
					"lwc.checkcode",
					new String(hander.getQueryValue("lwc.checkcode").getBytes(
							"ISO-8859-1"), "UTF-8"), SearchCondition.OP_LIKE);
		}
		if (!"".equals(hander.getQueryValue("lwc.oricode"))
				&& hander.getQueryValue("lwc.oricode") != null) {
			scs.addCondition(
					"lwc.oricode",
					new String(hander.getQueryValue("lwc.oricode").getBytes(
							"ISO-8859-1"), "UTF-8"), SearchCondition.OP_LIKE);
		}
		scs.setLimitPage(false);
		scs.addCondition("lwc.billstatus", "1",SearchCondition.OP_EQUAL);
		 Map<String,Object> sqlMap = SqlUtil.sqlUtil.roleWhSqlFilter(request, scUserRolePlaceService,"lwc.whcode");
		 scs.addCondition((String)sqlMap.get("option"), (List)sqlMap.get("roleWhList"));
		scs.setLimitPage(false);
		SearchResult result = logicWHCheckService.findListDetatils(scs);
		List<LogicWhCheckDetailsDO> list = result.getResults();
		
		ExcelUtil.toExcel(list, "盘点任务单号:checkMissionCode┋盘点单号:checkCode┋盘点人:agent┋仓库编码:whCode┋盘点仓库:whName┋物料编码:code┋物料名称:name┋物料类型:maType┋型号:spec┋批次:batch┋单位:unit┋总库存数量:quantityWH┋总盘点数量:quantityPD┋总差异数量:quantityCY┋一等品库存数量:ydengQuantityWH┋一等品盘点数量:ydengQuantityPD┋一等品差异数量:ydengQuantityCY┋次品库存数量:cipinQuantityWH┋次品盘点数量:cipinQuantityPD┋次品差异数量:cipinQuantityCY┋旧品库存数量:jiupinQuantityWH┋旧品盘点数量:jiupinQuantityPD┋旧品差异数量:jiupinQuantityCY┋冻结库存数量:freezeQuantityWH┋冻结盘点数量:freezeQuantityPD┋冻结差异数量:freezeQuantityCY┋盘点日期:pdDate┋备注:remark","盘点导出",response);
	}


	@RequestMapping("/upload")
	public String uploadmanager(HttpServletRequest request, Model model)
			throws Exception {
		model.addAttribute("wh",SqlUtil.sqlUtil.roleWH(request, scUserRolePlaceService));
		return UPLOAD;
	}

	@RequestMapping("/uploadsave")
	public String upload(HttpServletRequest request, Model model)
			throws Exception {
		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		MultipartFile file = multipartRequest.getFile("filename");
		String oriCode = multipartRequest.getParameter("oriCode");
		String whCode = multipartRequest.getParameter("whCode");
		String whName = multipartRequest.getParameter("whName");
		String agent = multipartRequest.getParameter("agent");
		String pdDate = multipartRequest.getParameter("pdDate");
		List<LogicWhCheckItemDO> checklist = new ArrayList<LogicWhCheckItemDO>();
		LogicWhCheckDO  checkdo = new LogicWhCheckDO();
		checkdo.setOriCode(oriCode);
		checkdo.setWhCode(whCode);
		checkdo.setWhName(whName);
		checkdo.setAgent(agent);
		if (pdDate != null && !"".equals(pdDate)) {
			checkdo.setPdDate(DateUtils.stringToDate(pdDate));
		}	
		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
		HSSFSheet sheet = wb.getSheetAt(0);
		for (int j = 1; j <= sheet.getLastRowNum(); j++) {
			LogicWhCheckItemDO whcheckitem = new LogicWhCheckItemDO();
			HSSFRow row = sheet.getRow(j);
			if (row == null) {
				continue;
			}
			whcheckitem.setCode(getStringCellValue(row.getCell(0)));
			whcheckitem.setName(getStringCellValue(row.getCell(1)));
			whcheckitem.setMaType(getStringCellValue(row.getCell(2)));
			whcheckitem.setSpec(getStringCellValue(row.getCell(3)));
			whcheckitem.setBatch(getStringCellValue(row.getCell(4)));
		//	whcheckitem.setStatus(getStringCellValue(row.getCell(5)));
			if (getStringCellValue(row.getCell(5)).equals("一等品")) {
				whcheckitem.setStatus("1");
			}
			if (getStringCellValue(row.getCell(5)).equals("次品")) {
				whcheckitem.setStatus("2");
			}
			if (getStringCellValue(row.getCell(5)).equals("旧品")) {
				whcheckitem.setStatus("3");
			}
			whcheckitem.setUnit(getStringCellValue(row.getCell(6)));
			whcheckitem.setQuantityWH(Double.parseDouble(getStringCellValue(row
					.getCell(7)) == "" ? "0" : getStringCellValue(row
					.getCell(7))));
			whcheckitem.setQuantityPD(Double.parseDouble(getStringCellValue(row
					.getCell(8)) == "" ? "0" : getStringCellValue(row
					.getCell(8))));
			whcheckitem.setQuantityCY(Double.parseDouble(getStringCellValue(row
					.getCell(8)) == "" ? "0" : getStringCellValue(row
					.getCell(8)))- Double.parseDouble(getStringCellValue(row
					.getCell(7)) == "" ? "0": getStringCellValue(row.getCell(7))));
			whcheckitem.setYdengQuantityWH(Double.parseDouble(getStringCellValue(row
					.getCell(10)) == "" ? "0" : getStringCellValue(row
					.getCell(10))));
			whcheckitem.setYdengQuantityPD(Double.parseDouble(getStringCellValue(row
					.getCell(11)) == "" ? "0" : getStringCellValue(row
					.getCell(11))));
			whcheckitem.setYdengQuantityCY(Double.parseDouble(getStringCellValue(row
					.getCell(11)) == "" ? "0" : getStringCellValue(row
					.getCell(11)))- Double.parseDouble(getStringCellValue(row
					.getCell(10)) == "" ? "0": getStringCellValue(row.getCell(10))));
			whcheckitem.setCipinQuantityWH(Double.parseDouble(getStringCellValue(row
					.getCell(13)) == "" ? "0" : getStringCellValue(row
					.getCell(13))));
			whcheckitem.setCipinQuantityPD(Double.parseDouble(getStringCellValue(row
					.getCell(14)) == "" ? "0" : getStringCellValue(row
					.getCell(14))));
			whcheckitem.setCipinQuantityCY(Double.parseDouble(getStringCellValue(row
					.getCell(14)) == "" ? "0" : getStringCellValue(row
					.getCell(14)))- Double.parseDouble(getStringCellValue(row
					.getCell(13)) == "" ? "0": getStringCellValue(row.getCell(13))));
			whcheckitem.setJiupinQuantityWH(Double.parseDouble(getStringCellValue(row
					.getCell(16)) == "" ? "0" : getStringCellValue(row
					.getCell(16))));
			whcheckitem.setJiupinQuantityPD(Double.parseDouble(getStringCellValue(row
					.getCell(17)) == "" ? "0" : getStringCellValue(row
					.getCell(17))));
			whcheckitem.setJiupinQuantityCY(Double.parseDouble(getStringCellValue(row
					.getCell(17)) == "" ? "0" : getStringCellValue(row
					.getCell(17)))- Double.parseDouble(getStringCellValue(row
					.getCell(16)) == "" ? "0": getStringCellValue(row.getCell(16))));
			whcheckitem.setFreezeQuantityWH(Double.parseDouble(getStringCellValue(row
					.getCell(19)) == "" ? "0" : getStringCellValue(row
					.getCell(19))));
			whcheckitem.setFreezeQuantityPD(Double.parseDouble(getStringCellValue(row
					.getCell(20)) == "" ? "0" : getStringCellValue(row
					.getCell(20))));
			whcheckitem.setFreezeQuantityCY(Double.parseDouble(getStringCellValue(row
					.getCell(20)) == "" ? "0" : getStringCellValue(row
					.getCell(20)))- Double.parseDouble(getStringCellValue(row
					.getCell(19)) == "" ? "0": getStringCellValue(row.getCell(19))));
			whcheckitem.setRemark(getStringCellValue(row.getCell(22)));
			checklist.add(whcheckitem);
		}
		model.addAttribute("pd", checkdo);
		model.addAttribute("uploaditemlist", checklist);
		model.addAttribute("flag", "upload");
	//	model.addAttribute("wh",SqlUtil.sqlUtil.roleWH(request, scUserRolePlaceService));
		return EIDT;
	}
	/** * 获取单元格数据内容为字符串类型的数据 * * @param cell Excel单元格 * @return String 单元格数据内容 */
	private String getStringCellValue(HSSFCell cell) {
		String strCell = "";
		switch (cell.getCellType()) {
		case HSSFCell.CELL_TYPE_STRING:
			strCell = cell.getStringCellValue();
			break;
		case HSSFCell.CELL_TYPE_NUMERIC:
			strCell = String.valueOf(cell.getNumericCellValue());
			break;
		case HSSFCell.CELL_TYPE_BOOLEAN:
			strCell = String.valueOf(cell.getBooleanCellValue());
			break;
		case HSSFCell.CELL_TYPE_BLANK:
			strCell = "";
			break;
		default:
			strCell = "";
			break;
		}
		if (strCell.equals("") || strCell == null) {
			return "";
		}
	/*	if (cell == null) {
			return "";
		}*/
		return strCell;
	}

	/** * 获取单元格数据内容为日期类型的数据 * * @param cell * Excel单元格 * @return String 单元格数据内容 */
	private String getDateCellValue(HSSFCell cell) {
		String result = "";
		try {
			int cellType = cell.getCellType();
			if (cellType == HSSFCell.CELL_TYPE_NUMERIC) {
				Date date = cell.getDateCellValue();
				result = (date.getYear() + 1900) + "-" + (date.getMonth() + 1)
						+ "-" + date.getDate();
			} else if (cellType == HSSFCell.CELL_TYPE_STRING) {
				String date = getStringCellValue(cell);
				result = date.replaceAll("[年月]", "-").replace("日", "").trim();
			} else if (cellType == HSSFCell.CELL_TYPE_BLANK) {
				result = "";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
}
